package utilityClasses;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class FileOutput {
	BufferedWriter bw = null;
	File newFile;
	
	public FileOutput(String fileName) {
		openFile(fileName);
	}

	public void closeFile() {
		try {
			if (bw != null) {
				bw.flush();
				bw.close();
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}
	
	private void openFile(String fileName) {
		newFile = new File(fileName);
		try {
			bw = new BufferedWriter(new FileWriter(newFile));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void print(String str) {
		try {
			if (bw != null) {
				bw.write(str);
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}

	}
	
	public void println(String str) {
		print(str + "\r\n");
	}
	
	public void flush() {
		try {
			if (bw!= null)
			bw.flush();
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}
	
	
}
